package com.mo.lib.utils.view

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions

/**
 * @ author：mo
 * @ data：2021/9/14:15:05
 * @ 功能：
 */

fun ImageView.loadImage(url: String, loadingResId: Int, errorResId: Int) {
    Glide.with(context).load(url).apply(RequestOptions.errorOf(errorResId).placeholder(loadingResId)).into(this)
}

fun ImageView.loadImage(url: String, errorResId: Int) {
    loadImage(url, errorResId, errorResId)
}

fun ImageView.loadImage(url: String) {
    Glide.with(context).load(url).into(this)
}

fun ImageView.loadImage(url: String, options: RequestOptions) {
    Glide.with(context).load(url).apply(options).into(this)
}
fun ImageView.loadImage2(url: String, options: RequestOptions): ImageView {
  return  Glide.with(context).load(url).apply(options).into(this).view
}